Ext.application({
            name : 'App',
            appFolder : 'App',
            autoCreateViewport : 'App.Viewport',
            init : function(application)
                                                            {
                                                                Ext.log.info('development:true');
                                                                Ext.log.info('context:' + context);
                                                                Ext.log.info('libsPath:' + libsPath);
                                                                Ext.log.info('extPath:' + extPath);
                                                                Ext.log.info('theme:' + theme);
                                                                window.app = window.App = window.Application = window.application = application;
                                                                Ext.Ajax.disableCachingParam = 'dc';
                                                                // 配置Ajax请求事件处理函数
                                                                Ext.Ajax.on({
                                                                            beforerequest : function(conn, options, eOpts)
                                                                            {
                                                                                var timeout = options.timeout;
                                                                                if (timeout <= 30 * 1000)
                                                                                {
                                                                                    timeout = 120 * 1000;
                                                                                }
                                                                                var method="POST";
                                                                                if(options.method=='_GET'){
                                                                                    method="GET";
                                                                                }
                                                                                // 配置全局请求参数
                                                                                Ext.apply(options, {
                                                                                            timeout : timeout,
                                                                                            method : method,
                                                                                            url : options.url.replace(/_dc=/, 'dc='),
                                                                                            defaultHeaders : {
                                                                                                'request_type' : 'ajax'
                                                                                            }
                                                                                        })
                                                                                Ext.log({
                                                                                            level : 'info',
                                                                                            msg : 'Request:' + options.url,
                                                                                            dump : options
                                                                                        });
                                                                            },
                                                                            requestcomplete : function(conn, resp, options, eOpts)
                                                                            {
                                                                                Ext.log({
                                                                                            level : 'info',
                                                                                            msg : 'Response:' + options.url,
                                                                                            dump : resp
                                                                                        });
                                                                                // 取得此次请求的url地址
                                                                                var url = options.url;
                                                                                if (!Ext.String.startsWith(url, 'http'))
                                                                                {
                                                                                    url = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1)
                                                                                            + url;
                                                                                }
                                                                                var text = resp.responseText;
                                                                                text = Ext.String.trim(text);
                                                                                // 判断是否是json字符串格式
                                                                                if ((Ext.String.startsWith(text, '{') && Ext.String.endsWith(text, '\}'))
                                                                                        || (Ext.String.startsWith(text, '[') && Ext.String.endsWith(text, ']')))
                                                                                {
                                                                                    try
                                                                                    {
                                                                                        resp.result = Ext.decode(text);
                                                                                    } catch (e)
                                                                                    {
                                                                                        var error = '返回数据不是合法的JSON格式!';
                                                                                        Extend.Msg.error('错误', error, {
                                                                                                    '返回数据' : text
                                                                                                });
                                                                                        return;
                                                                                    }
                                                                                    if (!Ext.isEmpty(resp.result))
                                                                                    {
                                                                                        if (resp.result.success === false)
                                                                                        {
                                                                                            if (!Ext.isEmpty(resp.result.status))
                                                                                            {
                                                                                                // 如果状态为-1表达未登录，2表示登录失败，1表示登录成功,3表示无权限访问
                                                                                                if (resp.result.status === -1)
                                                                                                {
                                                                                                    application.login(options);
                                                                                                } else if (resp.result.status === 3)
                                                                                                {
                                                                                                    Extend.Msg.error('错误', resp.result.result);
                                                                                                }
                                                                                                return;
                                                                                            }
                                                                                            if (isDebug)
                                                                                            {
                                                                                                var error = resp.result.result
                                                                                                        ? resp.result.result
                                                                                                        : (resp.result.exception
                                                                                                                ? '业务处理发生异常！'
                                                                                                                : '业务处理失败：处理结果"success"为"false"！');
                                                                                                Extend.Msg.error("错误", resp.result.result, resp.result.messages,
                                                                                                        resp.result.errors, resp.result.exception);
                                                                                            } else
                                                                                            {
                                                                                                Extend.Msg.error("错误", resp.result.result, resp.result.messages,
                                                                                                        resp.result.errors);
                                                                                            }
                                                                                            return;
                                                                                        } else
                                                                                        {
                                                                                            if (!Ext.isEmpty(resp.result.errors))
                                                                                            {
                                                                                                Extend.Msg.error("错误", resp.result.result || "请求发生错误：" + url,
                                                                                                        resp.result.messages, resp.result.errors);
                                                                                            }
                                                                                        }

                                                                                    }
                                                                                } else if (text.indexOf("<html>") > -1)
                                                                                {
                                                                                    var responseText = null;
                                                                                    if (isDebug === true)
                                                                                    {
                                                                                        responseText = text;
                                                                                    }
                                                                                    if (text.indexOf("There is no Action mapped for namespace") > -1)
                                                                                    {
                                                                                        var error = '请求的Action不存在:' + url;
                                                                                        Extend.Msg.error("错误", error, responseText);
                                                                                        var result = "{\"success\":false,\"result\":\"" + error + "\"}";
                                                                                        resp.responseText = result;
                                                                                        resp.result = Ext.decode(result);
                                                                                    } else if (text.indexOf('Struts Problem Report') > -1)
                                                                                    {
                                                                                        var error = '请求的Action发生异常:' + url;
                                                                                        Extend.Msg.error("错误", error, responseText);
                                                                                        var result = '{"success":false,"exception":"' + responseText + '","result":"'
                                                                                                + error + '"}';
                                                                                        resp.responseText = result;
                                                                                        resp.result = Ext.decode(result);
                                                                                    }
                                                                                }
                                                                            },
                                                                            requestexception : function(conn, resp, options, eOpts)
                                                                            {
                                                                                Ext.log({
                                                                                            level : 'error',
                                                                                            msg : 'Response:' + options.url,
                                                                                            dump : resp
                                                                                        });
                                                                                var status = resp.status;
                                                                                var detail = null;
                                                                                var url = options.url;
                                                                                if (!Ext.String.startsWith(url, 'http'))
                                                                                {
                                                                                    url = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1)
                                                                                            + url;
                                                                                }
                                                                                if (isDebug)
                                                                                {
                                                                                    detail = {
                                                                                        "Status code:" : resp.status,
                                                                                        "Status text:" : resp.statusText
                                                                                    };
                                                                                    if (!Ext.isEmpty(resp.responseText))
                                                                                    {
                                                                                        detail['Detail:'] = resp.responseText;
                                                                                    }
                                                                                }
                                                                                if (status === 0 && resp.timedout === true)
                                                                                {
                                                                                    var error = '请求超时：' + url;
                                                                                    Extend.Msg.error('错误(status=' + status + ')', error);
                                                                                } else if (status === 404)
                                                                                {
                                                                                    var error = '请求地址未找到：' + url;
                                                                                    Extend.Msg.error('错误(status=' + status + ')', error, detail);
                                                                                } else if (status === -1)
                                                                                {
                                                                                    var error = '请求终止：' + url;
                                                                                    Ext.log.warn(error);
                                                                                } else
                                                                                {
                                                                                    var error = '请求发生错误:' + url;
                                                                                    Extend.Msg.error('错误(status=' + status + ')', error, detail);
                                                                                }
                                                                            }
                                                                        });
                                                            }
        });